package com.huixue.cn.ztej.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import com.huixue.cn.ztej.utils.Config;
import com.huixue.cn.ztej.utils.Strings;


public class BaseController extends MultiActionController {

	protected Logger logger = Logger.getLogger(this.getClass());

	private static final long serialVersionUID = 6357869213649815390L;
	
	private static String BASE_PATH = null;
	
	/**得到ModelAndView
	 * @return
	 */
	public ModelAndView getModelAndView(){
		return new ModelAndView();
	}
	
	protected String downloadBaseURL(HttpServletRequest request) {
		String configBase = Config.getString("server.download.base.url");
		if (BASE_PATH != null && BASE_PATH.equalsIgnoreCase(configBase))
			return BASE_PATH;
		if (Strings.isEmpty(configBase)) {
			String path = request.getContextPath();
			String basePath = request.getScheme() + "://" + request.getServerName() + ":"
					+ request.getServerPort() + path + "/";
			BASE_PATH = basePath;
		} else {
			BASE_PATH = configBase;
		}
		return BASE_PATH;
	}

}
